using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace System.IPod
{
	public class DataString : Node
	{
		internal MhodString m_mhodString;
		string m_value;

		public string Value
		{
			get { return m_value; }
		}

		protected override int Size
		{
			get { return 16 + m_mhodString.String.Length; } // 16 = int Position, int Length, int Unknown3, int Unknown4;
		}

		protected override void ReadImpl(BinaryReader reader)
		{
			m_mhodString = new MhodString();
			m_mhodString.Read(reader);
			m_value = StringReadUtil.GetUnicodeString(m_mhodString.String);
		}

		protected override void WriteImpl(BinaryWriter writer)
		{
			m_mhodString.Write(writer);
		}

		protected override void SetSize(int size)
		{
			
		}

		internal static DataObject CreateString(string value, int type)
		{
			DataObject dataObj = new DataObject();
			dataObj.m_mhod = Mhod.Create();
			dataObj.m_mhod.Type = type;

			DataString dataString = new DataString();
			dataString.m_mhodString = MhodString.Create(value);
			dataObj.AddChild(dataString);

			return dataObj;
		}
	}
}
